/**
 * @author liqiang
 * @date 2018年11月5日
 * @desc
 *
 */
package com.bgc.codegenerate;

import com.bgc.codegenerate.utils.CodeGeneratorUtil;
import com.bgc.codegenerate.utils.ConfigurationParser;
import com.bgc.codegenerate.utils.GenerateConfiguration;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class CodeGenerate {

	public static final String DB_URL = "jdbc:mysql://127.0.0.1:3306/world?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull";
	public static final String DB_USER = "root";
	public static final String DB_PWD = "123456";
	public static final String DB_DRIVER = "com.mysql.cj.jdbc.Driver";

	public static final String author = "biguochao";

	// 项目基础package路径
	public static final String BASE_PACKAGE = "com.bgc.code_generate";

	// 表格前缀，可以为空；如果为空，生成的对象则为表格名称去掉下划线转驼峰，如果有值则去掉前缀，转为驼峰对象，
	// e.g 表格名称：t_user，TABLE_PREFIX为空； entity：TUser,
	// TABLE_PREFIX="t_"，entity：User
	public static final String TABLE_PREFIX = "";

	/**
	 * @author liqiang149
	 * @throws Exception
	 * @throws Exception
	 * @date 2018年11月5日
	 * @desc
	 *       1、tables填写表名即可，数据库表要求有id主键字段
	 *
	 */
	public static void main(String[] args) {
		GenerateConfiguration configuration;
		String[] tables = { "country"};
		try {
			for (int i = 0; i < tables.length; i++) {
				configuration = ConfigurationParser.parseConfiguration(tables[i]);
				configuration.setAuthor(author);
				// 主键类型
				configuration.setPkName("code");
				configuration.setPkSqlName("Code");
				configuration.setPkTypeJava("String");
				CodeGeneratorUtil.generate(configuration);
			}

		} catch (Exception e) {
			log.error("occur an error...", e);
		}

	}
}
